<?php

namespace App\Listeners;

use App\Notifications\RegisterMailNotify;
use Illuminate\Auth\Events\Registered;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Notification;
class RegisterListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  Registered  $event
     * @return void
     */
    public function handle(Registered $event)
    {
    	//注册完后生成email_token
        $user=$event->user;
        $user->email_token=str_random (10);
        $user->save();
        //发送激活邮件,给当前注册用户发送激活邮件
		Notification::send ($user,new RegisterMailNotify($user));
    }
}
